Screenshot taken from Coursera
Answer
Screenshot taken from Coursera
Answer
In [2]:
import graphlab
graphlab.canvas.set_target('ipynb')
x = graphlab.SFrame({'x1':[1,0,1,0],'x2':['1','1','0','0'],'x3':['1','0','1','1'],'y':['1','-1','-1','1']})
x
Out[2]:
In [3]:
features = ['x1','x2','x3']
target = 'y'
decision_tree_model = graphlab.decision_tree_classifier.create(x, validation_set=None,
target = target, features = features)
In [4]:
decision_tree_model.show()
In [11]:
decision_tree_model.show(view="Tree")
Screenshot taken from Coursera
In [14]:
# Accuracy
print decision_tree_model.evaluate(x)['accuracy']
Screenshot taken from Coursera
Screenshot taken from Coursera
Screenshot taken from Coursera
Screenshot taken from Coursera
Screenshot taken from Coursera
Screenshot taken from Coursera
Screenshot taken from Coursera
Screenshot taken from Coursera